// components/scroll-video.js
var s = "";
Component({
  options: {
    multipleSlots: true // 在组件定义时的选项中启用多slot支持
  },
  /**
   * 组件的属性列表
   */
  properties: {
    
  },

  /**
   * 组件的初始数据
   */
  data: {
    time: 0,
    buy_user: "",
    buy_address: "",
    buy_time: 0,
    buy_type: "",
    getInfo: true
  },
  /**
   * 组件的属性列表
   */
  properties: {
    
  },
  created:function(){
    var that = this;
    that.suspension();
  },
  /**
   * 组件的方法列表
   */
  methods: {    
    suspension: function() {
      var e = this;
      var i = setInterval(function() {
        if (e.data.getInfo) {
          if (e.data.buy_user) {
            e.setData({
              buy_user: "",
              buy_type: "",
              buy_url: '',
              buy_address: "",
              buy_avatar_url: "",
              buy_time: ""
            })
            return false;
          }
          getApp().request({
            url:  getApp().api.default.buy_data,
            data: {
              time: e.data.time
            },
            method: "POST",
            success: function(t) {
              if (0 == t.code) {
                var a = !1;
                var tt = wx.getStorageSync("store");
                tt && tt.av_purchase_frame == 0 && s == t.md5 && (a = !0);
                var i = "",
                  o = t.cha_time,
                  r = Math.floor(o / 60 - 60 * Math.floor(o / 3600));
                i = 0 == r ? o % 60 + "秒" : r + "分" + o % 60 + "秒";
                var n = "购买了",
                  d = "/pages/goods/goods?id=" + t.data.goods;
                2 === t.data.type ? (n = "预约了", d = "/pages/book/details/details?id=" + t.data.goods) : 3 === t.data.type ? (n = "秒杀了",
                  d = "/pages/miaosha/details/details?id=" + t.data.goods) : 4 === t.data.type && (n = "拼团了",
                  d = "/pt/details/details?gid=" + t.data.goods), !a && t.cha_time <= 1000 ? (e.setData({
                  buy_time: i,
                  buy_type: n,
                  buy_url: d,
                  buy_user: t.data.user.length >= 5 ? t.data.user.slice(0, 4) + "..." : t.data.user,
                  buy_avatar_url: t.data.avatar_url,
                  buy_address: t.data.address.length >= 8 ? t.data.address.slice(0, 7) + "..." : t.data.address
                }), s = t.md5) : e.setData({
                  buy_user: "",
                  buy_type: "",
                  buy_url: d,
                  buy_address: "",  
                  buy_avatar_url: "",
                  buy_time: ""
                });
              }
            }
          });
        }
        
      }, 1e4);
    },
    resetData: function() {

    },
    onConfirm: function(t) {
      
    },
    hideGoodsModel: function() {
      this.setData({
        showModal: !1
      });
    },
    detached: function() {
      this.setData({
        getInfo: false
      })
    },
  }
})
